<!-- 预警详情 -->
<template>
	<view class="page">
		<cu-custom bgColor="bg-white" :isBack="true">
			<block style="color: ##777777;font-size: 48rpx;" slot="content">预警详情</block>
		</cu-custom>
		<view class="content">
			<ul>
				<li>
					<text>预警名称：{{title}}</text>
				</li>
				<li>
					<text>预警设备：{{yjry}}</text>
				</li>
				<li>
					<text>上报时间：{{time}}</text>
				</li>
				<li>
					<text>业主名称：{{yzmc}}</text>
				</li>
				<li>
					<text style="line-height: 23rpx;text-align: center;">预警信息：{{info}}</text>
				</li>
				<li>
					<text>所属区域：{{address | strFormat}}</text>
				</li>
			</ul>
		</view>

		<view v-if="feedtype == -1" class="flex btns-group">
			<button class="my-btn-grpup" @click="sbwb">设备误报</button>
			<button class="my-btn-grpup" @click="qrhq">确认火情</button>
		</view>

	</view>
</template>

<script>
	import * as constants from '@/common/config.js';
	export default {
		onLoad(option) {
			this.ucId = option.ucId
			this.noticeInfoId = option.noticeInfoId
			// 封装参数
			let params = {
				"ucId": option.ucId
			}
			let that = this
			// 请求数据
			let app = getApp()
			app.globalData.request({
				url: '/wx/fireAlarmInfo/getInFireAlarmInfoVo',
				data: {
					...params
				}
			}).then(function(res) {
				console.info(res)

				that.title = res.data.data.name
				that.yjry = res.data.data.equipmentName
				that.time = res.data.data.alarmTime
				that.yzmc = res.data.data.enterpriseName
				that.info = res.data.data.alarmInfo
				that.address = res.data.data.location

				that.ucId = res.data.data.ucId
				that.feedtype = res.data.data.feedtype
				that.equipmentId = res.data.data.equipmentId
			}).catch(function(e) {

			})
		},
		data() {
			return {
				title: '',
				yjry: '',
				time: '',
				yzmc: '',
				info: '',
				address: '',

				ucId: '',
				feedtype: '',
				equipmentId: '',
				imgUrl:'',
				noticeInfoId:''
			}
		},
		methods: {
			sbwb() {
				uni.navigateTo({
					url: '/yzqy/sbwb/sbwb?equipmentId=' + this.equipmentId + "&ucId=" + this.ucId
				});
				// let that = this
				// let params = {
				// 	ucId: this.ucId,
				// 	feedtype: 0,
				// 	feedback: "设备误报"
				// }
				// // 生成报警信息
				// let app = getApp()
				// app.globalData.request({
				// 	url: '/wx/fireAlarmInfo/updateInFireAlarmInfo',
				// 	data: {
				// 		...params
				// 	}
				// }).then(function(res) {
				// 	let data = res.data.code
				// 	console.info("data:" + data)
				// 	if (data == 0) {
				// 		uni.navigateTo({
				// 			url: '/yzqy/sbwb/sbwb?equipmentId=' + that.equipmentId + "&ucId=" + that.ucId
				// 		});
				// 	}

				// }).catch(function(e) {})

			},
			qrhq() {
				
				// 确认火情之后要  录制视频  确认火情报警接口
				// 报警成功 页面。。。。
				// 结束火情，弹框提醒。确认之后拍照接口。。。
				// 首先拍照片
				let that = this
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['camera'], //从相册选择
					success: (res) => {
						let path = res.tempFilePaths
						console.info("路径:"+path)
						// 上传
						let app = getApp()
						let token = app.globalData.getToken('authorization')
						uni.uploadFile({
							url: constants.API + 'wx/common/upload',
							filePath: path[0],
							header: {
								"authorization": token
							},
							name: 'file',
							success: (uploadFileRes) => {
								
								that.imgUrl = uploadFileRes.data.data
								
								
								// 确认火情
								let params = {
									ucId: that.ucId,
									equipmentId: that.equipmentId,
									alarmInfoId: that.ucId,
									drill: 0
								}
								let app = getApp()
								app.globalData.request({
									url: 'wx/firealarm/equipmentFireNotice',
									data: {
										...params
									}
								}).then(function(res) {
									let data = res.data.code
									console.info("data:" + data)
									if (data == 0) {
										// uni.showToast({
										// 	title: "确认火情成功",
										// 	icon: 'success'
										// })
										uni.navigateTo({
											url:'../bjcg/bjcg?noticeId='+this.noticeInfoId
										})
								
									}else{
										uni.showToast({
											title: "确认火情失败",
											icon: 'error'
										})
									}
								
								}).catch(function(e) {
									uni.showToast({
										title: "操作失败",
										icon: 'error'
									})
								})
							}
						});
						
					}
				});
				
				
				
			},
		}
	}
</script>

<style scoped>
	page {
		width: 100vw;
		position: relative;
	}

	.content {
		margin-top: 24rpx;
		background-color: #FFFFFF;
	}

	li {
		height: 94rpx;
		margin-left: 24rpx;
		margin-right: 24rpx;
		position: relative;
	}


	li text {
		font-size: 24rpx;
		color: #777777;
		letter-spacing: 0.39px;
		line-height: 94rpx;
	}

	li::after {
		content: ''; // 必须
		position: absolute;
		left: 2rpx;
		bottom: 0;
		right: 2rpx;
		height: 1px;
		background-color: #dcdcdc;
	}

	.my-btn {
		height: 94rpx;
		background-image: linear-gradient(90deg, #FAB53A 4%, #EFA21A 99%);
		box-shadow: 0 0 12px 0 rgba(250, 181, 58, 0.50);
		border-radius: 24px;
		ont-family: PingFangSC-Medium;
		color: #FFFFFF;
		letter-spacing: 0;
		text-align: center;
	}

	.my-btn-grpup {
		height: 160rpx;
		line-height: 160rpx;
		vertical-align: middle;
		text-align: center;
	}

	.btns-group {
		width: 100%;
		position: absolute;
		bottom: 0;
		text-align: center;
		display: flex;
		flex-direction: row;
		align-items: flex-end;
	}

	.btns-group button:first-child {
		background-color: #458DF5;
		color: #FFFFFF;
		flex: 1;
		font-size: 36rpx;
		outline: none;
		border: none;
		margin: 0;
		padding: 0;
		border: 1px solid transparent;
		border-radius: 0;
		border-top-left-radius: 16px;
	}

	.btns-group button:nth-child(2) {
		background-color: #54BE7A;
		color: #FFFFFF;
		flex: 1;
		font-size: 36rpx;
		outline: none;
		border: none;
		margin: 0;
		padding: 0;
		border: 1px solid transparent;
		border-radius: 0;
	}

	.btns-group button:last-child {
		background-color: #FABD50;
		flex: 1;
		color: #FFFFFF;
		font-size: 36rpx;
		outline: none;
		border: none;
		margin: 0;
		padding: 0;
		border: 1px solid transparent;
		border-radius: 0;
		border-top-right-radius: 16px;
	}

	.my-flag {
		position: relative;
	}

	.action::before {
		position: absolute;
		left: 18rpx;
		width: 6rpx;
		height: 32rpx;
		content: '';
		background: #FAB539;

	}
</style>
